global input "Q:\dc1prhcmsas01\PU2\data - sas"
global temp "Q:\dc1prhcmsas01\PU2\temp_stata_wr"
global log "Q:\dc1prhcmsas01\PU2\Log - Stata WR"
global output "Q:\dc1prhcmsas01\PU2\data_stata_wr"
global graphs "Q:\dc1prhcmsas01\PU2\graphs_stata_wr"
global tables "Q:\dc1prhcmsas01\PU2\tables_stata_wr"

cd "Q:\dc1prhcmsas01\PU2\Code - Stata WR"
set scheme plotplain
graph set window fontface "Times New Roman"

capture log close
log using "$log/7_plot_reg_growth", replace

*Program to estimate regressions
cap program drop plot_est
program define plot_est 
args var name ytitle ylabel

	*Save estimates
	use "$output/`name'_estimates.dta", clear
	
	if "`var'"=="retire" | "`var'"=="health" {
		drop if event_time<-11
	}
	
	*Plot estimates
	graph twoway (connect beta event_time, lc(black) mcolor(black) legend(off)) (rcap ub lb event_time, color(black) legend(off)) , ///
		xline(-7 0) xtitle("Months since Dec 2016") xlabel(-20(5)20) ///
		yline(0) ytitle(`ytitle') ylabel(`ylabel') legend(off)
	graph export "$graphs/`name'.eps", replace
	graph export "$graphs/`name'.jpg", replace	
end 

****************************************
*Plots based on Dec 2016 Characteristics
****************************************
*Fig 5b
	plot_est base fig5b_base "Weekly Base Pay" -10(10)40
	plot_est ot fig5b_ot "Weekly OT Pay" -5(1)5	
	plot_est log_base fig5b_log_base "Log Weekly Base Pay" -0.01(0.01)0.04
	plot_est log_ot fig5b_log_ot "Log Weekly OT Pay" -0.2(0.1)0.3
	plot_est retire fig5b_retire "Avg. Weekly Retirement Contributions" -10(2)10
	plot_est health fig5b_health "Avg. Weekly Health Contributions" -10(2)10
	
*Fig A2
	plot_est base figA2_base_placebo "Weekly Base Pay" -10(10)40
	
*Fig 5c
	plot_est base fig5c_base "Weekly Base Pay" -10(10)40
	plot_est ot fig5c_ot "Weekly OT Pay" -5(1)5
	plot_est log_base fig5c_log_base "Log Weekly Base Pay" -0.01(0.01)0.04	
	plot_est log_ot fig5c_log_ot "Log Weekly OT Pay" -0.2(0.1)0.3
	plot_est retire fig5c_retire "Avg. Weekly Retirement Contributions" -10(2)10
	plot_est health fig5c_health "Avg. Weekly Health Contributions" -10(2)10
	
*Fig 5d
	plot_est base fig5d_base "Weekly Base Pay" -20(20)120
	plot_est ot fig5d_ot "Weekly OT Pay" -10(5)5
	plot_est log_base fig5d_log_base "Log Weekly Base Pay" -0.05(0.05)0.15
	plot_est log_ot fig5d_log_ot "Log Weekly OT Pay" -0.3(0.1)0.3
	plot_est retire fig5d_retire "Avg. Weekly Retirement Contributions" -10(2)10
	plot_est health fig5d_health "Avg. Weekly Health Contributions" -10(2)10
	
*Fig A3
	plot_est base figA3_base "Weekly Base Pay" -20(20)120
	plot_est ot figA3_ot "Weekly OT Pay" -10(5)5
	plot_est log_base figA3_log_base "Log Weekly Base Pay" -0.05(0.05)0.15
	plot_est log_ot figA3_log_ot "Log Weekly OT Pay" -0.3(0.1)0.3

****************************************
*Plots based on Apr 2016 Characteristics
****************************************
*Fig 5b
	plot_est base fig5b_base_apr "Weekly Base Pay" -10(10)40
	plot_est ot fig5b_ot_apr "Weekly OT Pay" -5(1)5	
	plot_est log_base fig5b_log_base_apr "Log Weekly Base Pay" -0.01(0.01)0.04
	plot_est log_ot fig5b_log_ot_apr "Log Weekly OT Pay" -0.2(0.1)0.3
	plot_est retire fig5b_retire_apr "Avg. Weekly Retirement Contributions" -10(2)10
	plot_est health fig5b_health_apr "Avg. Weekly Health Contributions" -10(2)10
	
*Fig 5c
	plot_est base fig5c_base_apr "Weekly Base Pay" -10(10)40
	plot_est ot fig5c_ot_apr "Weekly OT Pay" -5(1)5	
	plot_est log_base fig5c_log_base_apr "Log Weekly Base Pay" -0.01(0.01)0.04
	plot_est log_ot fig5c_log_ot_apr "Log Weekly OT Pay" -0.2(0.1)0.3
	plot_est retire fig5c_retire_apr "Avg. Weekly Retirement Contributions" -10(2)10
	plot_est health fig5c_health_apr "Avg. Weekly Health Contributions" -10(2)10
	
*Reclassifications 
	plot_est salaried fig5b_salaried_apr "Probability Salaried"
	plot_est salaried fig5c_salaried_apr "Probability Salaried"
	plot_est ot fig5b_ot_apr_455 "Weekly OT Pay" -5(1)5	
	plot_est ot fig5c_ot_apr_455 "Weekly OT Pay" -5(1)5	
	
log close